﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>明细表属性</title>
    <link href="../../Scripts/easyUI15/themes/default/easyui.css" rel="stylesheet" type="text/css" />
    <link href="../../Scripts/easyUI15/themes/icon.css" rel="stylesheet" type="text/css" />
    <link href="../../Comm/Style/Table0.css" rel="stylesheet" type="text/css" />
    <link href="../../Comm/Style/Tabs.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="../../Scripts/bootstrap/js/jquery.min.js"></script>
    <script type="text/javascript" src="../../Scripts/bootstrap/js/bootstrap.min.js"></script>
    <script src="../../Scripts/easyUI15/jquery.easyui.min.js" type="text/javascript"></script>
    <script src="../../Scripts/QueryString.js" type="text/javascript"></script>

    <script src="../../Scripts/EasyUIUtility.js" type="text/javascript"></script>
    <script src="../../Scripts/config.js" type="text/javascript"></script>
	<script src="../../Comm/Gener.js" type="text/javascript"></script>

    <base target="_self" />
      <script type="text/javascript">

		closeWhileEscUp();

        //页面启动函数.
          $(function () {

              $("#Msg").html("<img src=../../Img/loading.gif />&nbsp;正在加载,请稍后......");

              //公共变量.
              //表单ID.
              var fk_mapData = GetQueryString("FK_MapData");
              //明细表ID.
              var fk_mapDtl = GetQueryString("FK_MapDtl");

              var myurl = Handler + "?DoType=DtlAttrs&FK_MapData=" + fk_mapData + "&FK_MapDtl=" + fk_mapDtl + "&m=" + Math.random();

              //初始化 GroupID.
              $.ajax({
                  type: 'post',
                  async: true,
                  url: Handler + "?DoType=DtlAttrs&FK_MapData=" + fk_mapData + "&FK_MapDtl=" + fk_mapDtl + "&m=" + Math.random(),
                  dataType: 'html',
                  success: function (data) {

                      data = JSON.parse(data);

                      $("#trTitle").append("<th>序</th>");

                      var colNum = 0;
                      //生成表头..
                      for (var i = 0; i < data.length; i++) {
                          var visable = data[i].UIVisible;
                          if (visable == 0)
                              continue;

                          colNum++;

                          var mypk = data[i].MyPK;
                          var dataType = data[i].MyDataType;
                          var field = data[i].KeyOfEn;
                          var name = data[i].Name;
                          var lgType = data[i].LGType;
                          var uiBindKey = data[i].UIBindKey;
                          var uiContralType = data[i].UIContralType; //控件类型.
                          var uiWidth = data[i].UIWidth; //宽度.

                          var nameLink = "";
                          if (lgType == 0) {
                              nameLink = "<a href=\"javascript:Edit('" + mypk + "','" + dataType + "')\" > " + name + "</a>";
                          }

                          if (lgType == 1) {
                              nameLink = "<a href=\"javascript:EditEnumForDtl('" + fk_mapDtl + "','" + mypk + "','" + uiBindKey + "')\" > " + name + "</a>";
                          }

                          if (lgType == 2) {
                              nameLink = "<a href=\"javascript:EditTable('" + fk_mapDtl + "','" + mypk + "','" + uiBindKey + "')\" > " + name + "</a>";
                          }

                          var col = "";
                          if (dataType == 2 || dataType == 3 || dataType == 5 || dataType == 6 || dataType == 8)
                              col = "<th style='word-break: keep-all;' nowarp=true ><a href=\"javascript:Up('" + fk_mapData + "','" + mypk + "');\" ><img src='../../../WF/Img/Btn/Left.gif' /></a>" + nameLink + "<a href=\"javascript:Down('" + fk_mapData + "','" + mypk + "')\" ><img src='../../../WF/Img/Btn/Right.gif' /></a></th>";
                          else
                              col = "<th style='width:" + uiWidth + "px;word-break: keep-all;' nowarp=true ><a href=\"javascript:Up('" + fk_mapData + "','" + mypk + "');\" ><img src='../../../WF/Img/Btn/Left.gif' /></a>" + nameLink + "<a href=\"javascript:Down('" + fk_mapData + "','" + mypk + "')\" ><img src='../../../WF/Img/Btn/Right.gif' /></a></th>";

                          $("#trTitle").append(col);
                      }


                      //生成内容行.
                      for (var idx = 0; idx < 6; idx++) {


                          var newRow = "<tr><td class=Idx >" + idx + "</td>";

                          //   for (var colIdx = 0; colIdx < colNum; colIdx++) {

                          for (var i = 0; i < data.length; i++) {
                              var visable = data[i].UIVisible;
                              if (visable == 0)
                                  continue;

                              var mypk = data[i].MyPK;
                              var dataType = data[i].MyDataType;
                              var field = data[i].KeyOfEn;
                              var name = data[i].Name;
                              var lgType = data[i].LGType;
                              var uiBindKey = data[i].UIBindKey;
                              var uiContralType = data[i].UIContralType; //控件类型.
                              var uiWidth = data[i].UIWidth; //宽度.
                              var defVal = data[i].DefVal; //默认值.

                              var td = "";
                              td = "<td >" + defVal + "</td>";

                              //doubble, float 类型.
                              if (dataType == 3 || dataType == 5 || dataType == 2 )
                                  td = "<td style='text-align:right'  >" + defVal + "</td>";

                              //money 类型.
                              if (dataType == 8)
                                  td = "<td style='text-align:right' >" + defVal + "</td>";

                              //日期类型.
                              if (dataType == 6) {
                                  td = "<td >yyyy-MM-dd</td>";
                              }

                              //日期时间类型.
                              if (dataType == 7) {
                                  td = "<td >yyyy-MM-dd HH:mm</td>";
                              }

                              if (dataType == 4) {
                                  td = "<td ><input type=checkbox value='1' id=" + field+"_"+ i+ " />" + name + "</td>";
                              }


                              if (uiContralType ==1 )
                                  td = "<td >[下拉框]</td>";


                              newRow += td;
                          }

                          newRow += "</tr>";
                          $("#dtlTable tr:last").after(newRow);
                      }
                  }
              });

              $("#Msg").html("");

          });


          function AddF(fk_mapdata) {

              var url = 'FieldTypeList.htm?FK_MapData=' + fk_mapdata;
              OpenEasyUiDialog(url, "eudlgframe", '新增字段', 800, 500, "icon-property", true, null, null, null, function () {
                  window.location.href = window.location.href;

              });

              //  var b = window.showModalDialog(url, 'ass', 'dialogHeight: 500px; dialogWidth: 600px;center: yes; help: no');
              //window.location.href = window.location.href;
          }
        function AddFGroup(fk_mapdata) {
            var url = 'Do.aspx?DoType=AddFGroup&FK_MapData=' + fk_mapdata;
            var b = window.showModalDialog(url, 'ass', 'dialogHeight: 500px; dialogWidth: 600px;center: yes; help: no');
            window.location.href = window.location.href;
        }
        function CopyF(fk_mapdata) {
            var url = 'CopyDtlField.htm?FK_MapData=' + fk_mapdata + '&s=' + Math.random();
            var b = window.showModalDialog(url, 'ass', 'dialogHeight: 600px; dialogWidth: 800px;center: yes; help: no');
            window.location.href = window.location.href;
        }

        function HidAttr(mypk) {
            var url = 'HidAttr.htm?FK_MapData=' + mypk + '&s=' + Math.random();
            var b = window.showModalDialog(url, 'ass', 'dialogHeight: 600px; dialogWidth: 800px;center: yes; help: no');
            //  window.location.href = window.location.href;
        }
        function Edit(mypk, ftype) {
            var parentwin = parent.window;
            if (parentwin) {

                var iFrame = parentwin.document.getElementById("F");
                if (iFrame && iFrame.contentWindow && iFrame.contentWindow.location.href == location.href) {
                    parentwin.Edit(mypk, ftype);
                    return;
                }
                parentwin.Edit(mypk, ftype);
                //alert("err");
                return;
            }

            var url = '';
            var title = ''

            //普通字段类型.
            if (ftype == "1") {
                url = "../../Comm/En.htm?EnName=BP.Sys.FrmUI.MapAttrString&inlayer=1&PKVal=" + mypk;
                title = '字段String属性';
            }

            //数值字段类型.
            if (ftype == "2") {
                url = "../../Comm/En.htm?EnName=BP.Sys.FrmUI.MapAttrNum&inlayer=1&PKVal=" + mypk;
                title = '字段Int属性';
            }

            //数值字段类型.
            if (ftype == "3") {
                url = "../../Comm/En.htm?EnName=BP.Sys.FrmUI.MapAttrNum&inlayer=1&PKVal=" + mypk;
                title = '字段Float属性';
            }

            //数值字段类型.
            if (ftype == "5") {
                url = "../../Comm/En.htm?EnName=BP.Sys.FrmUI.MapAttrNum&inlayer=1&PKVal=" + mypk;
                title = '字段Double属性';
            }

            //数值字段类型.
            if (ftype == "8") {
                url = "../../Comm/En.htm?EnName=BP.Sys.FrmUI.MapAttrNum&inlayer=1&PKVal=" + mypk;
                title = '字段Moeny属性';
            }


            //日期类型date.
            if (ftype == "6") {
                url = "../../Comm/En.htm?EnName=BP.Sys.FrmUI.MapAttrDT&inlayer=1&PKVal=" + mypk;
                title = '字段Date属性';

            }

            //日期类型datetime.
            if (ftype == "7") {
                url = "../../Comm/En.htm?EnName=BP.Sys.FrmUI.MapAttrDT&inlayer=1&PKVal=" + mypk;
                title = '字段DateTime属性';
            }

            // boolen 类型.
            if (ftype == "4") {
                url = "../../Comm/En.htm?EnName=BP.Sys.FrmUI.MapAttrBoolen&inlayer=1&PKVal=" + mypk;
                title = '字段Boolen属性';
            }

            if (url == '') {
                alert('@没有判断的类型' + ftype);
                return;
            }
            
            OpenEasyUiDialog(url, "eudlgframe", title, 800, 500, "icon-edit", true, null, null, null, function () {
                window.location.href = window.location.href;
            });
        }

        function EditEnumForDtl(fk_mapdata, mypk, enumKey) {

            var parentwin = parent.window;
            if (parentwin) {
                var iFrame = parentwin.document.getElementById("F");

                if (iFrame && iFrame.contentWindow && iFrame.contentWindow.location.href == location.href) {
                    parentwin.EditEnum(fk_mapdata, mypk, enumKey);
                    return;
                }
                parentwin.EditEnum(fk_mapdata, mypk, enumKey);
                return;
            }

            var url = '../../Comm/En.htm?EnName=BP.Sys.FrmUI.MapAttrEnum&inlayer=1&PKVal=' + mypk + '&s=' + Math.random();

            OpenEasyUiDialog(url, "eudlgframe", "编辑枚举字段", 800, 500, "icon-edit", true, null, null, null, function () {
                window.location.href = window.location.href;
            });
        }
        function EditTable(fk_mapdata, mypk, fk_sfTable) {

            var parentwin = parent.window;

            if (parentwin) {

                var iFrame = parentwin.document.getElementById("F");


                if (iFrame && iFrame.contentWindow && iFrame.contentWindow.location.href == location.href) {
                    parentwin.EditTable(fk_mapdata, mypk, fk_sfTable);
                    return;
                }

                parentwin.EditTable(fk_sfTable, mypk, fk_mapdata);
                return;
            }

            var url = '../../Comm/En.htm?EnName=BP.Sys.FrmUI.MapAttrSFTable&inlayer=1&PKVal=' + mypk + '&s=' + Math.random();

            OpenEasyUiDialog(url, "eudlgframe", "外键字段属性", 800, 500, "icon-edit", true, null, null, null, function () {
                window.location.href = window.location.href;
            });

        }

        function closeDlg() {
            $("#eudlg").dialog("close");
        }

        function Up(fk_mapdata, mypk) {
            var param = {
                DoType: "DtlFieldUp",
                MyPK: mypk
            };

            Handler_AjaxQueryData(param, function (data) {
                if (data.indexOf("err@") != -1) {
                    $.messager.alert("错误", data, "icon-error");
                    return;
                }

                window.location.href = window.location.href;
            }, this);
        }
        function Down(fk_mapdata, mypk) {
            var param = {
                DoType: "DtlFieldDown",
                MyPK: mypk
            };

            Handler_AjaxQueryData(param, function (data) {
                if (data.indexOf("err@") != -1) {
                    $.messager.alert("错误", data, "icon-error");
                    return;
                }

                window.location.href = window.location.href;
            }, this);
        }
        function Del(fk_mapdata, refNo) {
            if (window.confirm('您确定要删除吗？') == false)
                return;

            var url = 'Do.aspx?DoType=Del&MyPK=' + fk_mapdata + '&RefNo=' + refNo;
            var b = window.showModalDialog(url, 'ass', 'dialogHeight: 400px; dialogWidth: 600px;center: yes; help: no');
            window.location.href = window.location.href;
        }
        function DtlMTR(MyPK) {
            var url = 'MapDtlMTR.aspx?MyPK=' + MyPK + '&s=' + Math.random();
            var b = window.showModalDialog(url, 'ass', 'dialogHeight: 350px; dialogWidth: 550px;center: yes; help: no');
            window.location.href = window.location.href;
        }
        function Esc() {
            if (event.keyCode == 27)
                window.close();
            return true;
        }
        function Attachment(fk_mapdtl) {
            var url = 'Attachment.aspx?IsBTitle=1&PKVal=0&FK_MapData=' + fk_mapdtl + '&FK_FrmAttachment=' + fk_mapdtl + '_AthMDtl&Ath=AthMDtl&s=' + Math.random();
            window.showModalDialog(url, 'xx','dialogWidth=750px;dialogHeight=700px');
        }
        function MapM2M(fk_mapdtl) {
            window.showModalDialog('MapM2M.aspx?NoOfObj=M2M&PKVal=0&FK_MapData=' + fk_mapdtl + '&FK_FrmAttachment=' + fk_mapdtl + '_AthMDtl&Ath=AthMDtl&s=' + Math.random());
        }
      </script>
</head>
<body>
<table id='dtlTable' >
<tr id='trTitle'>
</tr>

</table>


</body>
</html>
